package sport;
import java.sql.*;

public class DBConnection {
  public static Connection conn;
  public static Statement stmt;

  public static void connect(){
    try{
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      conn=DriverManager.getConnection(
          "jdbc:mysql://gow.dyndns.info/sportlk", "lkinfo", "42pizzas"
        );
      stmt=conn.createStatement(
          ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    } catch (Exception ex){
      conn=null;
      stmt=null;
      System.out.println("Fehler: "+ex);
    }
  }

  public static int[] getIntArray(String select){
    int[] alle=null;
    try{
      ResultSet res=stmt.executeQuery(select);
      res.last();
      int len=res.getRow();
      alle=new int[len];
      res.afterLast();
      while(res.previous()) alle[--len]=res.getInt(1);
    } catch(SQLException ex){
      System.out.println("Fehler: "+ex);
    }
    return alle;
  }
}
